<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>客户管理系统</title>
</head>
<body>
<h1>客户管理系统</h1>
<h2>注册</h2>
<form id="registerForm">
    用户名: <input type="text" id="regUsername"><br>
    密码: <input type="password" id="regPassword"><br>
    <button type="button" onclick="register()">注册</button>
</form>
<h2>登录</h2>
<form id="loginForm">
    用户名: <input type="text" id="loginUsername"><br>
    密码: <input type="password" id="loginPassword"><br>
    <button type="button" onclick="login()">登录</button>
</form>
<script>
    function register() {
        const username = document.getElementById('regUsername').value;
        const password = document.getElementById('regPassword').value;
        fetch('/api/users/register', {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({ username, password })
        }).then(response => response.text()).then(alert);
    }
    function login() {
        const username = document.getElementById('loginUsername').value;
        const password = document.getElementById('loginPassword').value;
        fetch(`/api/users/login?username=${username}&password=${password}`, {
            method: 'POST'
        }).then(response => response.text()).then(alert);
    }
</script>
</body>
</html>
